﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FrontEnd
{
    /// <summary>
    /// A signal that indicates the start of data.
    /// </summary>
    public class DataStartSignal: Signal
    {
        private Int32 _sampleRate;

        public Int32 SampleRate
        {
            get { return _sampleRate; }
        }
        /**
        /// A constant that is attached to all DataStartSignal passing this component. This allows subsequent
        /// <code>DataProcessor</code>s (like the <code>Scorer</code>) to adapt their processing behavior.
         */
        public static String SPEECH_TAGGED_FEATURE_STREAM = "vadTaggedFeatureStream";


        /**
        /// Constructs a DataStartSignal.
         *
        /// @param sampleRate The sampling rate of the started data stream.
         */
        public DataStartSignal(int sampleRate):
            this(sampleRate, DateTime.Now.Ticks)
        {
            
        }


        /**
        /// Constructs a DataStartSignal at the given time.
         *
        /// @param sampleRate the sampling rate of the started data stream.
        /// @param time       the time this DataStartSignal is created
         */
        public DataStartSignal(int sampleRate, long time):
            this(sampleRate, time, false)
        {
            
        }


        /**
        /// Constructs a DataStartSignal at the given time.
         *
        /// @param sampleRate  the sampling rate of the started data stream.
        /// @param tagAsVadStream <code>true</code> if this feature stream will contain vad-signals
         */
        public DataStartSignal(int sampleRate, Boolean tagAsVadStream) 
            :this(sampleRate, DateTime.Now.Ticks, tagAsVadStream)
        {
            
        }


        /**
        /// Constructs a DataStartSignal at the given time.
         *
        /// @param sampleRate  the sampling rate of the started data stream.
        /// @param time        the time this DataStartSignal is created
        /// @param tagAsVadStream <code>true</code> if this feature stream will contain vad-signals
         */
        public DataStartSignal(int sample_Rate, long time, Boolean tagAsVadStream) 
            :base(time)
        {
            
            _sampleRate = sample_Rate;

            if (tagAsVadStream) {
                this.getProps().Add(SPEECH_TAGGED_FEATURE_STREAM, tagAsVadStream);
            }
        }

        /// @return the string "DataStartSignal"
        override
        public String ToString() 
        {
            return "DataStartSignal: creation time: " + getTime();
        }

        public static void tagAsVadStream(DataStartSignal dsSignal) 
        {
            dsSignal.getProps().Add(DataStartSignal.SPEECH_TAGGED_FEATURE_STREAM, true);
        }


        public static void untagAsVadStream(DataStartSignal dsSignal) 
        {
            dsSignal.getProps().Remove(DataStartSignal.SPEECH_TAGGED_FEATURE_STREAM);
        }
    }
}
